// pages/character/get/get.js
const app = getApp()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    testData: {
      character: {
        id: 1,
        nameZh: '李有志',
        nameEn: 'Lee Youzhi',
        gender: '男',
        age: 20,
        raceName: '半兽人',
        classesName: '战士'
      },
      ability: {
        strength: 10,
        dexterity: 10,
        constitution: 10,
        intelligence: 10,
        wisdom: 10,
        charisma: 10,
      },
      skills: [{
        skillName: '技能1',
        skillMod: 2
      }, {
        skillName: '技能2',
        skillMod: 3
      }, {
        skillName: '技能3',
        skillMod: 4
      }, {
        skillName: '技能4',
        skillMod: 5
      }],
      load: {
        light: 1,
        med: 2,
        max: 3,
        overHead: '4',
        offGround: '5',
        pushDrag: '6'
      }
    }
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options.name)
    wx.setNavigationBarTitle({
      title: '角色详情',
    })
    wx.request({
      url: app.globalData.domain +'/assistant/character/get',
      data: { "name": options.name},
      method: "POST",
      success: res => {
        console.log(res.data)
        this.setData(res.data)
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },

  /**
   * 用户点击右上角分享
   */
  deleteConfirm: function () {
    wx.showModal({
      title: '确认删除此人物',
      content: '人物删除后不可恢复，请注意！',
      confirmText: "删除",
      cancelText: "取消",
      success: function (res) {
        console.log(res);
        if (res.confirm) {
          console.log('已删除')
        } else {
          console.log('已取消')
        }
      }
    });
  }
})